package cg.modelo;

import java.util.ArrayList;

public abstract class BoardZone implements CardContainer{

	private ArrayList<Card> cards;

	public BoardZone() {
		this.cards = new ArrayList<Card>();
	}
	
	public int size() {
		return this.cards.size();
	}

	public void add(Card card) {
		this.cards.add(card);
	}

	public void add(ArrayList<Card> cards) {
		for(Card card: cards)
			this.cards.add(card);
	}
	
	public boolean hasCard(Card card) {
		return this.cards.contains(card);
	}
	
	private boolean empty() {
		return (this.size() == 0);
	}
	
	public Card removeCard() {
		if(!this.empty()) 
			return this.cards.remove(0);
		return null;
	}

	public ArrayList<Card> removeCards(int quantity) {
		if(!this.empty()) {
			ArrayList<Card> removeCard = new ArrayList<Card>(quantity);
			for(int i=0; i<quantity; i++) {
				removeCard.add(this.removeCard());
			}
			return removeCard;
		}
		//agregar excepcion
		return null;
	}

	public ArrayList<Card> removeAllCards() {
		return this.removeCards(this.size());
	}
	
	public Card removeCard(Card card) {
		if(this.cards.contains(card)) {
			int index = this.cards.indexOf(card);
			return this.cards.remove(index);
		}
		return null;
	}
	
	public boolean full() {
		return (this.size() == 5);
	}

}
